package com.example.springdemo;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

@RestController
@RequestMapping("/wms/web")
public class WuLiaoController {

    private static final Logger log = LoggerFactory.getLogger(WuLiaoController.class);

    @CrossOrigin
    @GetMapping(value = "/get_login_key")
    public Object get_login_key2(Object request) {
        return "{\"returnCode\":1,\"returnMsg\":\"成功\",\"data\":\"d4505efd-10ae-42ba-a4bb-d7b7223fa106\"}";
    }

    @CrossOrigin
    @PostMapping(value = "/get_login_key")
    public Object get_login_key(Object request) {
        return "{\"returnCode\":1,\"returnMsg\":\"成功\",\"data\":\"d4505efd-10ae-42ba-a4bb-d7b7223fa106\"}";
    }

    @CrossOrigin
    @PostMapping(value = "/loginAd")
    public Object loginAd(Object request) {
        return "{\n" +
                "    \"returnCode\": 1,\n" +
                "    \"returnMsg\": \"登录成功\",\n" +
                "    \"data\": {\n" +
                "        \"msg\": \"登录成功\",\n" +
                "        \"code\": \"0\",\n" +
                "        \"token\": \"1bf09e0b-8e44-4859-9997-dfc9b4a1e600\"\n" +
                "    }\n" +
                "}";
    }


    @CrossOrigin
    @PostMapping(value = "/getRoleByList")
    public Object getRoleByList(Object request) {
        return "{\"returnCode\":1,\"returnMsg\":\"成功\",\"data\":[{\"roleName\":\"DJXG\",\"hasRole\":true}]}";
    }


    @CrossOrigin
    @PostMapping(value = "/cus_ship_list/get_task_and_platform_list")
    public Object get_task_and_platform_list(Object request) {
        // 未实现
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_task_and_platform_list.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "/mat_manage/getList")
    public Object getList() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("getList.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @GetMapping(value = "/input/inspect_input/get_inspect_input_info/{orderNo}")
    public Object get_inspect_input_info(@PathVariable String orderNo) {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_inspect_input_info.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


    @CrossOrigin
    @PostMapping(value = "/output/other_output/get_other_out_list")
    public Object get_other_out_list() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_other_out_list.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


    @CrossOrigin
    @PostMapping(value = "/output/other_output/get_other_output_info")
    public Object get_other_output_info() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_other_output_info.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @GetMapping(value = "/output/other_output/get_move_type_list")
    public Object get_move_type_list() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_move_type_list.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    //审批流1
    @CrossOrigin
    @PostMapping(value = "/wf/receipt/get_node_by_id")
    public Object get_node_by_id() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_node_by_id.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    //审批流2
    @CrossOrigin
    @PostMapping(value = "/wf/approve/get_approve_user")
    public Object get_approve_user() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_approve_user_two.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "/mat_manage/getMatManageOptionList")
    public Object getMatManageOptionList() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("getMatManageOptionList.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @GetMapping(value = "/mat_manage/getList_rj")
    public Object getList_rj() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("getList_rj.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * 接收-列表
     *
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "/mat_manage/getInputList")
    public Object getList_js() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("getList_js.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "/mat_manage/matInputArrival")
    public Object matInputArrival(@RequestBody Object input) {
        log.info(input.toString());
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("matInputArrival.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "/mat_manage/inputArrival")
    public Object inputArrival(@RequestBody Object input) {
        log.info(input.toString());
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("matInputArrival.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * {
     * "facility": "HZ21",
     * "pageIndex": 1,
     * "pageSize": 10,
     * "paging": true,
     * "sortColumn": "",
     * "sortAscend": "",
     * "totalCount": -1
     * }
     *
     * @return
     */
    //设施管理（模糊查询）
    @CrossOrigin
    @PostMapping(value = "/dic/plat_form/get_list")
    public Object get_list_sheshi() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_list_sheshi.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    //库存地点
    @CrossOrigin
    @PostMapping(value = "dic/stock/query_list")
    public Object query_list_kucun() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("query_list_kucun.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    //库存地点
    @CrossOrigin
    @PostMapping(value = "dic/stock/query")
    public Object query_stock() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("query_stock.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "auth/get_all_location_real_wh")
    public Object get_all_location_real_wh() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_all_location_real_wh.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "mat_manage/getCusMatManageListOnPaging")
    public Object getCusMatManageListOnPaging() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("getCusMatManageListOnPaging.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "mat_manage/submit")
    public Object submit(@RequestBody Object input) {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("matInputArrival.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "mat_manage/deleteById/{id}")
    public Object submit(@PathVariable String id) {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("matInputArrival.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "mat_manage/getCusMatManageInfo")
    public Object getCusMatManageInfo() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("getCusMatManageInfo.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @GetMapping(value = "wf/approve/get_modular_list")
    public Object get_modular_list() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_modular_list.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "wf/approve/get_approval_list")
    public Object get_approval_list() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_approval_list.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "wf/approve/do_approve")
    public Object do_approve() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("matInputArrival.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @GetMapping(value = "dic/language/language_list")
    public Object language_list() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("language_list.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


    @CrossOrigin
    @PostMapping(value = "output/matreq_output/get_reserve_item_list")
    public Object get_reserve_item_list() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_reserve_item_list.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


    @CrossOrigin
    @PostMapping(value = "output/matreq_output/get_matreq_output_info")
    public Object get_matreq_output_info() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_matreq_output_info.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "auth/get_real_wh_list_fty")
    public Object get_real_wh_list_fty() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_real_wh_list_fty.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "auth/get_bin_tree_by_wh_list")
    public Object get_bin_tree_by_wh_list() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_bin_tree_by_wh_list.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "output/matreq_output/get_matreq_out_list")
    public Object get_matreq_out_list() {
        // 指定资源路径（相对于classpath根目录）
        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("get_matreq_out_list.json")) {
            if (inputStream == null) {
                return "File not found.";
            }
            // 将输入流转换为字符串
            return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @CrossOrigin
    @PostMapping(value = "output/matreq_output/submit")
    public Object matreq_output_submit(Object request) {
        //return "未实现";
        return "{\"returnCode\":1,\"returnMsg\":\"成功\",\"data\":\"d4505efd-10ae-42ba-a4bb-d7b7223fa106\"}";
    }

}





